from django.db import models
from django.forms import ModelForm

# Users - Need to check LDAP

class Role(models.Model):
    role_description = models.CharField(max_length=50)  #either Student or Teacher

class User(models.Model):
    name = models.CharField(max_length=50)
    email = models.CharField(max_length=20)
    role = models.ForeignKey(Role)

# Exam

class Department(models.Model):
    dept_description = models.CharField(max_length=50)  # Law, Business, Computer, ...

class ExamType(models.Model):
    type_description = models.CharField('type of exam', max_length=50)
    # Final, Midterm or whatever

class Exam(models.Model):
    remarks = models.CharField('Teachers remarks', max_length=250)
    course = models.CharField('Course name', max_length=50)
    create_date = models.DateTimeField(('%d/%m/%Y',), 'Create date')
    pub_date = models.DateField('Date published')
    begin_time = models.TimeField('Time begin')
    end_time = models.TimeField('Time end')
    dept = models.ForeignKey(Department, verbose_name='To what school department the exam belongs to')
    type = models.ForeignKey(ExamType, verbose_name='A type that describes the exam')
    #published = models.BooleanField(default=False) # teacher can publish the exam when ready
    # Many exams to each department and exam types


class User_Exams(models.Model):
    user_id = models.ForeignKey(User)
    exam_id = models.ForeignKey(Exam)
    grade = models.IntegerField()
    # submitted = models.BooleanField()
    # keep this as string
    # if a teacher creates an exam or user completes one

class Question(models.Model):
    exam = models.ForeignKey(Exam)                      # Many questions to one exam
    question = models.CharField('What is the question?', max_length=100)

class Answer(models.Model):                             # Many answers to one question
    answer = models.CharField('And one answer would be...', max_length=100)
    question = models.ForeignKey(Question)
    correct_answer = models.BooleanField()

class Exam_Result(models.Model):
    exam_id = models.ForeignKey(Exam)
    user_id = models.ForeignKey(User)
    question_id = models.ForeignKey(Question)
    answer_id = models.ForeignKey(Answer)
    correct_answer = models.BooleanField()

